
function Dep() {
  this.subs = []
}

Dep.prototype.addSub = function (sub) {
  this.subs.push(sub)
}

Dep.prototype.notify = function () {
  this.subs.forEach(sub => sub.update())
}

function Watch(fn) {
  this.fn = fn
}

Watch.prototype.update = function () {
  this.fn()
}

let watch = new Watch(function () {
  console.log(1111);
})

let dep = new Dep()

dep.addSub(watch)
dep.addSub(watch)
console.log(dep.subs);
dep.notify()